<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Returns a handle to an already running instance of a COM object</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.com-get-active-object" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">com_get_active_object</h1>
  <p class="verinfo">(PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">com_get_active_object</span> &mdash; <span class="dc-title">Returns a handle to an already running instance of a COM object</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.com-get-active-object-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>com_get_active_object</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$progid</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$code_page</code></span>
  ] ) : <span class="type"><a href="class.variant.html" class="type variant">variant</a></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>com_get_active_object()</strong></span> is similar to creating a new
   instance of a <a href="class.com.html" class="xref">COM</a> object, except that it will
   only return an object to your script if the object is already running.
   OLE applications use something known as the &quot;<em>Running Object Table</em>&quot; to
   allow well-known applications to be launched only once; this function
   exposes the COM library function GetActiveObject() to get a handle on a
   running instance.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.com-get-active-object-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">progid</code></dt>

     <dd>

      <p class="para">
       <code class="parameter">progid</code> must be either the ProgID or CLSID for
       the object that you want to access (for example
       <em>Word.Application</em>).
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">code_page</code></dt>

     <dd>

      <p class="para">
       Acts in precisely the same way that it does for the <a href="class.com.html" class="xref">COM</a> class.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.com-get-active-object-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   If the requested object is running, it will be returned to your script
   just like any other COM object.
  </p>
 </div>

 <div class="refsect1 errors" id="refsect1-function.com-get-active-object-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   There are a variety of reasons why this function might fail, the most
   common being that the object is not already running.  In that situation,
   the exception error code will be <strong><code>MK_E_UNAVAILABLE</code></strong>;
   you can use the <em>getCode</em> method of the exception object
   to check the exception code.
  </p>
 </div>

 <div class="refsect1 notes" id="refsect1-function.com-get-active-object-notes">
  <h3 class="title">注释</h3>
  <div class="warning"><strong class="warning">Warning</strong>
   <p class="para">
    Using <span class="function"><strong>com_get_active_object()</strong></span> in a web server context
    is not always a smart idea.  Most COM/OLE applications are not designed
    to handle more than one client concurrently, even (or especially!)
    Microsoft Office.  You should read <a href="http://support.microsoft.com/kb/257757" class="link external">&raquo;&nbsp;Considerations for Server-Side
    Automation of Office</a> for more information on the general issues
    involved.
   </p>
  </div>
 </div>

</div></div></div></body></html>